package com.sunday.volunteer.adapter;

import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sunday.volunteer.R;
import com.sunday.volunteer.entity.Activity;
import com.sunday.volunteer.entity.Product;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by admin on 2017/1/10.
 */

public class ActivityAdapter extends RecyclerViewAdapter {

    public ActivityAdapter(List list, int layout) {
        super(list, layout);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(View itemView, int viewType) {
        return new ViewHolder(itemView);
    }

    public class ViewHolder extends MyViewHolder {
        @Bind(R.id.name)
        TextView name;
        @Bind(R.id.time)
        TextView time;
        @Bind(R.id.address)
        TextView address;
        @Bind(R.id.count)
        TextView count;
        @Bind(R.id.group_name)
        TextView group_name;
        @Bind(R.id.btn)
        TextView btn;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            btn.setOnClickListener(onClickListener);
            itemView.setOnClickListener(onClickListener);
        }

        @Override
        public void bind(MyViewHolder holder, Object object, int position) {
            btn.setTag(position);
            itemView.setTag(position);
            Activity item = (Activity) object;
            setText(name, item.getName());
            setText(time, item.getTime());
            setText(address, item.getAddress());
            setText(count, item.getJoinNumber() + "人");
            setText(group_name, String.format("来自 %s", item.getGroupName()));

            btn.setVisibility(item.getStatus() == 6 ? View.VISIBLE : View.GONE);

        }
    }
}
